<?php

require './vendor/autoload.php';

$config = array(
    'database' => array(
        'host'=>'localhost',
        'user'=>'root',
        'password'=>'',
        'port'=>'3306',
        'dbname'=>'ccod',
        'driver'=>'pdo_mysql',
    ),
);
//链接数据库
$conn = \Doctrine\DBAL\DriverManager::getConnection($config['database']);
$conn->executeQuery("set names utf8");

$csvFile = fopen("1.csv",'r');
while ($csvData = fgetcsv($csvFile)) { //每次读取CSV里面的一行内容
    if (!is_numeric($csvData[1])) {
        continue;
    }
    $time = strtotime($csvData[5]);
    $month = date("Y-m", $time);
    $day   = date("Y-m-d", $time);
    $hour  = date("h", $time);
    $half  = $hour*2+(date("i", $time) >= 30 ? 1 : 0);

    try{
        $conn->insert("rep_queue_month", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "queue_secs" => 100,
            "ring_num" => 100,
            "lost1_num" => 100,
            "lost1_secs" => 100,
            "queue_id" => 2,
            "nowmonth" => $month,
        ));
        $conn->insert("rep_queue_day", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "queue_secs" => 100,
            "ring_num" => 100,
            "lost1_num" => 100,
            "lost1_secs" => 100,
            "queue_id" => 2,
            "nowdate" => $day,
        ));
        $conn->insert("rep_queue_hour", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "queue_secs" => 100,
            "ring_num" => 100,
            "lost1_num" => 100,
            "lost1_secs" => 100,
            "queue_id" => 2,
            "start_date" => $day,
            "time_stamp" => $hour,
        ));
        $conn->insert("rep_queue_halfhour", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "queue_secs" => 100,
            "ring_num" => 100,
            "lost1_num" => 100,
            "lost1_secs" => 100,
            "queue_id" => 2,
            "start_date" => $day,
            "time_stamp" => $half,
        ));

        $conn->insert("rep_system_month", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "ring_num" => 100,
            "ring_secs" => 100,
            "ivr_num" => 100,
            "nowmonth" => $month,
        ));
        $conn->insert("rep_system_day", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "ring_num" => 100,
            "ring_secs" => 100,
            "ivr_num" => 100,
            "nowdate" => $day,
        ));
        $conn->insert("rep_system_hour", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "ring_num" => 100,
            "ring_secs" => 100,
            "ivr_num" => 100,
            "start_date" => $day,
            "time_stamp" => $hour,
        ));
        $conn->insert("rep_system_halfhour", array(
            "vcc_id" => 2,
            "lost10_num" => 100,
            "lost20_num" => 100,
            "lost25_num" => 100,
            "lost30_num" => 100,
            "lost35_num" => 100,
            "lost40_num" => 100,
            "in_num" => 100,
            "lost_num" => 100,
            "lost_secs" => 100,
            "ring_num" => 100,
            "ring_secs" => 100,
            "ivr_num" => 100,
            "start_date" => $day,
            "time_stamp" => $half,
        ));

        $conn->insert("rep_phone_group_month", array(
            "vcc_id" => 2,
            "in_num" => 100,
            "lost_num" => 100,
            "ring_num" => 100,
            "ivr_num" => 100,
            "total_num" => 100,
            "server_num" => 100,
            "nowmonth" => $month,
        ));
        $conn->insert("rep_phone_group_day", array(
            "vcc_id" => 2,
            "in_num" => 100,
            "lost_num" => 100,
            "ring_num" => 100,
            "ivr_num" => 100,
            "total_num" => 100,
            "server_num" => 100,
            "nowdate" => $day,
        ));

        $conn->insert("rep_group_month", array(
            "vcc_id" => 2,
            "group_id" => 2,
            "in_num" => 100,
            "nowmonth" => $month,
        ));
        $conn->insert("rep_group_day", array(
            "vcc_id" => 2,
            "group_id" => 2,
            "in_num" => 100,
            "nowdate" => $day,
        ));
        $conn->insert("rep_group_hour", array(
            "vcc_id" => 2,
            "group_id" => 2,
            "in_num" => 100,
            "start_date" => $day,
            "time_stamp" => $hour,
        ));
        $conn->insert("rep_group_halfhour", array(
            "vcc_id" => 2,
            "group_id" => 2,
            "in_num" => 100,
            "start_date" => $day,
            "time_stamp" => $half,
        ));
    } catch (\Exception $e) {
        print_r($e->getMessage());
    }


}